<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <base href="#(basePath)"/>
  <title>交易管理 - 订单列表</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=1">
  <link rel="stylesheet" href="static/layui/css/layui.css" media="all">
  <link rel="stylesheet" href="static/admin.css" media="all">
  <style type="text/css">.layui-elem-quote span{margin:0 6px;}</style>
</head>
<body>
  <div class="layui-fluid">
    <div class="layui-card">
      <div class="layui-form layui-card-header layuiadmin-card-header-auto">
        <div class="layui-form-item">
          <div class="layui-inline">
            <label class="layui-form-label">客户编号</label>
            <div class="layui-input-inline">
              <input type="text" name="merchCode" placeholder="请输入" autocomplete="off" class="layui-input">
            </div>
          </div>

          <div class="layui-inline">
            <label class="layui-form-label">用户名称</label>
            <div class="layui-input-inline">
              <input type="text" name="merchName" placeholder="请输入" autocomplete="off" class="layui-input">
            </div>
          </div>


          <div class="layui-inline">
            <label class="layui-form-label">实名名称</label>
            <div class="layui-input-inline">
              <input type="text" name="myName" placeholder="请输入" autocomplete="off" class="layui-input">
            </div>
          </div>

          <div class="layui-inline">
            <label class="layui-form-label">交易对手信息</label>
            <div class="layui-input-inline">
              <input type="text" name="realName" placeholder="交易对手信息" autocomplete="off" class="layui-input">
            </div>
          </div>


          <div class="layui-inline">
            <label class="layui-form-label">金额范围</label>

              <div class="layui-input-inline" style="width: 100px;">
                <input type="text" onkeyup='upperCase(this)' name="price_min" placeholder="￥" autocomplete="off" class="layui-input" lay-verify="price_min">
              </div>
              <div class="layui-form-mid">-</div>
              <div class="layui-input-inline" style="width: 100px;">
                <input type="text" onkeyup='upperCase(this)' name="price_max" placeholder="￥" autocomplete="off" class="layui-input" lay-verify="price_max">
              </div>

          </div>


          <div class="layui-inline">
            <label class="layui-form-label">手续费</label>
            <div class="layui-input-inline">
              <select name="feeInfo">
                <option value="">请选择</option>
                <option value="1">大于0</option>
              </select>
            </div>
          </div>



          <div class="layui-inline">
            <label class="layui-form-label">钱包订单号</label>
            <div class="layui-input-inline">
              <input type="text" name="orderNo" placeholder="请输入" autocomplete="off" class="layui-input">
            </div>
          </div>

          <div class="layui-inline">
            <label class="layui-form-label">商城订单号</label>
            <div class="layui-input-inline">
              <input type="text" name="outOrderNo" placeholder="请输入" autocomplete="off" class="layui-input">
            </div>
          </div>
          <div class="layui-inline">
            <label class="layui-form-label">开始时间</label>
            <div class="layui-input-inline">
              <input type="text" class="layui-input" id="createTimeStart" name="createTimeStart" placeholder="yyyy-MM-dd HH:mm:ss" autocomplete="off">
            </div>
          </div>
          <div class="layui-inline">
            <label class="layui-form-label">结束时间</label>
            <div class="layui-input-inline">
              <input type="text" class="layui-input" id="createTimeEnd" name="createTimeEnd" placeholder="yyyy-MM-dd HH:mm:ss" autocomplete="off">
            </div>
          </div>
          <div class="layui-inline">
            <label class="layui-form-label">状态</label>
            <div class="layui-input-inline">
              <select name="orderStatus">
              <option value="">请选择</option>
              	#for(item : orderStatusList)
                <option value="#(item.code)">#(item.name)</option>
                #end
              </select>
            </div>
          </div>
          <div class="layui-inline">
            <label class="layui-form-label">交易类型</label>
            <div class="layui-input-inline">
              <select name="bizTypeList" multiple="multiple" lay-filter="bizType">
                <option value="">请选择</option>
                #for(item : bizTypeList)
                <option value="#(item.code)">#(item.name)</option>
                #end
              </select>
            </div>
          </div>
          <div class="layui-inline">
            <button class="layui-btn layuiadmin-btn-list" lay-submit lay-filter="LAY-web-list-search">
              <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
            </button>

            #auth()
            <button style="display: none" link="admin/order/report" class="layui-btn layuiadmin-btn-list" lay-submit lay-filter="exportExcel">
              <i class="layui-icon layui-icon-about layuiadmin-button-btn">导出对账表</i>
            </button>
            #end

            <button link="admin/order/reportSheet" class="layui-btn layuiadmin-btn-list" lay-submit lay-filter="exportExcelSheet">
              <i class="layui-icon layui-icon-about layuiadmin-button-btn">导出明细</i>
            </button>
          </div>
        </div>
      </div>

      <div class="layui-card-body">
        <div style="display:block">
      	<blockquote class="layui-elem-quote layui-quote-nm" id="totalinfo">
		    总手续费<span class="sumFee layui-badge layui-bg-orange">￥--.--</span>元，
		    总笔数<span class="sumCount layui-badge layui-bg-gray">-</span>笔
		</blockquote>
        </div>
        <table id="LAY-web-list" lay-filter="LAY-web-list"></table>
        <script type="text/html" id="table-content-list">
          #auth()
          <a link="admin/order/view" class="layui-btn layui-btn-normal layui-btn-xs" lay-event="view"><i class="layui-icon layui-icon-form"></i>详情</a>
		  #end
		#[[ {{#  if(d.orderStatus == 'TS'){ }} ]]#
          #auth()
          <a link="admin/order/certificate" class="layui-btn layui-btn-xs" lay-event="certificate"><i class="layui-icon layui-icon-auz"></i>回执</a>
          #end
         #[[ {{#  } }} ]]#
        </script>
      </div>
    </div>
  </div>

  <script src="static/layui/layui.js"></script>
  <script>
  layui.config({
    base: '#(basePath)' //静态资源所在路径
  }).extend({
    index: 'lib/index' //主入口模块
  }).use(['index', 'laydate', 'table', 'multiSelect', 'order'], function(){
	var laydate = layui.laydate;
    //日期时间选择器
    laydate.render({
      elem: '#createTimeStart'
      ,type: 'datetime'
    });
    laydate.render({
      elem: '#createTimeEnd'
      ,type: 'datetime'
    });

    // 表格
      var $ = layui.$, table = layui.table, form = layui.form;

      function isMoney(s) {
          if(isEmpty(s)){
              return true;
          }
          //金额 只允许正数
          //var exp = /(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/; 
          //金额 允许正（+）负数
          //var exp = /(^([+-]?)[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^([+-]?)(0){1}$)|(^([+-]?)[0-9]\.[0-9]([0-9])?$)/; 
          //金额 允许正负数
          var exp = /(^([-]?)[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^([-]?)(0){1}$)|(^([-]?)[0-9]\.[0-9]([0-9])?$)/;
          if(exp.test(s)) {
              return true;
          } else {
              return false;
          }
      }

      form.verify({
          price_min:function(value){
              if(!isMoney(value)){
                  return "请输入正确的金额(元为单位，两位小数点)";
              }
          },
          price_max:function (value) {
              if(!isMoney(value)){
                  return "请输入正确的金额(元为单位，两位小数点)";
              }
          }
      });

    //监听搜索
    form.on('submit(LAY-web-list-search)', function(data){
        var field = data.field;
        field.bizTypex="";
        var vals = [],
            texts = [];
        var tt = 1;
        $('select[multiple] option:selected').each(function() {
            field.bizTypex += $(this).val() + ";";
            vals.push($(this).val());
            texts.push($(this).text());
        });


      table.reload('LAY-web-list', {
        where: field,
        page: {curr: 1}
      });
    });

      //判断字符是否为空的方法
      function isEmpty(obj){
          if(typeof obj == "undefined" || obj == null || obj == ""){
              return true;
          }else{
              return false;
          }
      }

    form.on('submit(exportExcel)', function(data){
        var field = data.field;
        var createTimeStart = $("#createTimeStart").val();
        var createTimeEnd = $("#createTimeEnd").val();
        if(isEmpty(createTimeStart) || isEmpty(createTimeEnd)){
            layer.alert("导出Excel必须选择开始时间和结束时间，并且时间段建议不超过3个月!");
            return;
        }
        layer.msg("正在导出Excel表...");
        $.ajax({
            type:"POST",
            url:"admin/order/report",
            data:field,
            dataType: "JSON",
            success: function(data) {
                //alert(JSON.stringify(data));
                if(data.code==0){
                    window.location.href= data.msg;
                }else {
                    alert(JSON.stringify(data));
                }
            },
            error: function(XMLHttpRequest, textStatus, errorThrown) {
                alert("网络错误");
            }

        });
        //执行重载
        table.reload('LAY-web-list', {
            where: field,
            page: {curr: 1}
        });
    });




      form.on('submit(exportExcelSheet)', function(data){
          var field = data.field;
          var createTimeStart = $("#createTimeStart").val();
          var createTimeEnd = $("#createTimeEnd").val();
          if(isEmpty(createTimeStart) || isEmpty(createTimeEnd)){
              layer.alert("导出Excel必须选择开始时间和结束时间，并且时间段建议不超过3个月!");
              return;
          }

          field.bizTypex="";
          var vals = [],
              texts = [];
          var tt = 1;
          $('select[multiple] option:selected').each(function() {
              field.bizTypex += $(this).val() + ";";
              vals.push($(this).val());
              texts.push($(this).text());
          });


          layer.msg("正在导出Excel表...");
          $.ajax({
              type:"POST",
              url:"admin/order/reportSheet",
              data:field,
              dataType: "JSON",
              success: function(data) {
                  //alert(JSON.stringify(data));
                  if(data.code==0){
                      window.location.href= data.msg;
                  }else {
                      alert(JSON.stringify(data));
                  }
              },
              error: function(XMLHttpRequest, textStatus, errorThrown) {
                  alert("网络错误");
              }

          });
          //执行重载
          table.reload('LAY-web-list', {
              where: field,
              page: {curr: 1}
          });
      });

  });
  </script>
</body>
</html>
